<template>
  <div>
    <h1>首页</h1>
    <div>
      <button @click="setData">触发setData</button>
    </div>
  </div>
</template>

<script>
import { createNamespacedHelpers } from "vuex";
// import { mapMutations } from "vuex";
//利用工厂函数生成基于某个模块的辅助函数
const { mapMutations } = createNamespacedHelpers("user");
export default {
  methods: {
    // userSetData() {
    //   this.$store.commit("user/setData");
    // },
    //加了命名空间锁辅助函数写法
    // ...mapMutations("user", ["setData"]),

    ...mapMutations(["setData"]),
    // ...mapMutations({ globalmapMutations: "setData" }),
  },
};
</script>

<style>
</style>